import { fallbackRequestGet } from '@/utils/Request'

/**
 * 请求前缀，后面后台添加网关后需要前缀选择微服务
 */
const URL_PREFIX = 'middle-user/'

/**
 * 获取用户保存的所有地址信息
 * @param {Function} successCallback 成功回调，参数为data
 * @param {Function} fullCallback 肯定触发的回调，先于callback
 */
export const queryAllStoreAddress = (successCallback = null, fullCallback = null) => {
  return fallbackRequestGet(URL_PREFIX + 'storeAddress/queryAllStoreAddress', {}, {}, true, data => {
    if (successCallback) {
      successCallback(data)
    }
  }, null, fullCallback)
}

/**
 * 获取用户默认地址，不存在默认地址返回null
 * @param {Function} successCallback 成功回调，参数为data
 * @param {Function} fullCallback 肯定触发的回调，先于callback
 */
export const queryDefaultStoreAddress = (successCallback = null, fullCallback = null) => {
  return fallbackRequestGet(URL_PREFIX + 'storeAddress/queryDefaultStoreAddress', {}, {}, true, data => {
    if (successCallback) {
      successCallback(data)
    }
  }, null, fullCallback)
}
